<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p>vue的计算属性</p>
        <input type="text" v-model="first"> 
        + 
        <input type="text" v-model="second"> 
        =
        <span>{{cals()}} -------- {{result}}</span>
        <br>
        ------------------
        <p>{{cals()}} -------- {{result}}</p>
        <p>{{cals()}} -------- {{result}}</p>
        <p>{{cals()}} -------- {{result}}</p>
        <p>{{cals()}} -------- {{result}}</p>
        <p>{{cals()}} -------- {{result}}</p>
        <p>{{cals()}} -------- {{result}}</p>
        <br>
        -------------------

        <p>{{a}}</p>

        <input type="text" v-model="result">

    </div>
    <script src="./vue.global.js"></script>

    <script>
        const {createApp} = Vue;


        const app = createApp({
            data(){
                return {
                    first:'',
                    second:''
                }
            },
            methods:{
                cals(){
                    console.log('函数','我执行了一遍计算的操作');
                    return this.first-0 + (this.second-0)
                }
            },
            computed:{
                a(){
                    return 100;
                },
                result(){
                    console.log('计算属性','我执行了一遍计算的操作');
                    return this.first-0 + (this.second-0);
                    // 如果this.first 和 this.second 两个没有变化  
                    // 这个方法就不会再执行  
                    // 一旦发生变化  执行一次 
                }
            }
        });

        app.mount('#app')
    </script>
</body>
</html>